package com.geekstudy.week11;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;

public class UUIDTool {

    static final ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current();
    static AtomicLong atomicLong = new AtomicLong(1000000);

    public String uuid() {

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String currentTime = simpleDateFormat.format(new Date());

        long sequence = atomicLong.incrementAndGet();
        int random = threadLocalRandom.nextInt(100000, 999999);

        String uuid = currentTime + sequence + random;
        return uuid;
    }
}
